﻿#region Usings

using System;
using System.Collections.Generic;
using System.Runtime.Serialization;

#endregion

namespace Rail.Net.Core.Model.Nonpersistent
{
    [Serializable]
    [DataContract]
    public class ContengentTrainModel : IEquatable<ContengentTrainModel>
    {
        public ContengentTrainModel(string key, int domesticDistance, Relation relation)
        {
            Key = key;
            DomesticDistance = domesticDistance;
            Relation = relation;
            Connections = new List<ConnectionModel>();
        }

        [DataMember]
        public string Key { get; private set; }

        public int DomesticDistance { get; private set; }

        [DataMember]
        public Relation Relation { get; private set; }

        [DataMember]
        public List<ConnectionModel> Connections { get; private set; }

        public bool IsDomesticOnly
        {
            get
            {
                return Relation == null;
            }
        }

        public StationModel FirstStation
        {
            get { return Connections[0].FirstStation; }
        }

        public StationModel LastStation
        {
            get { return Connections[0].LastStation; }
        }

        #region IEquatable<ContengentTrainModel> Members

        public bool Equals(ContengentTrainModel other)
        {
            return Key == other.Key;
        }

        #endregion
    }
}